<?php 
$subcategory_url = url_for2('subcategory', array('subcategory' => $topic->getSubcategory(), 'page' => 1));
$category_url = url_for2('category', array('category' => $topic->getTopicSubcategory()->getCategory()));
$topic_url = url_for2('topic', array('topic' => $topic->getId(), 'page' => 1));
$forum_url = url_for('forum/categories');

echo <<<HTML
<a href="{$forum_url}">Forum</a> >>
<a href="{$category_url}">{$topic->getTopicSubcategory()->getSubcategoryCategory()->getName()}</a> >> 
<a href="{$subcategory_url}">{$topic->getTopicSubcategory()->getName()}</a> >>
<a href="{$topic_url}">{$topic->getName()}</a><br /><br /> 
HTML;
echo "<br />Synthèse :<br/>";
echo $topic->getSynthesis();
echo '<br /><a href="'.url_for2('edittopic', array('id' => $topic->getId())).'">Editer ce topic</a><br />';
?>

<table class="topic">
<?php 
foreach ($posts as $post)
{
	$edit = url_for2('editpost', array('id' => $post->getId()));
	
	$html = <<<HTML
	<tr>
		<td id="{$post->getId()}">
			Par {$post->getPostOwner()->getNickname()} :<br />
			<a href="$edit">Edit</a><br />
			{$post->getContent()}
		</td>
	</tr>
HTML;

	echo $html;
}
?>
</table>

<?php 
echo Utils::pagination($page, $total_posts, $posts_by_page, 'topic', array('topic' => $topic->getId()));
?>

<?php 
include_partial('forum/postform',
	array(
		'post' => $postform,
		'action' => url_for('forum/newpost')
	)
);
?>